// 配置webpack
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')

module.exports = {

  // 配置环境
  mode: 'development',

  // 入口文件配置
  entry: {
    app: './src/app.js'
  },

  // 出口文件配置 
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'app.js'
  },

  // 配置插件
  plugins: [
    new HtmlWebpackPlugin({
      template: path.join(__dirname, './public/index.html'),
      filename: 'index.html',
      inject: true
    }),  // html打包
    new CopyPlugin({
      patterns: [
        { from: "public/*.ico" },
      ],
    }),
  ],

  // 配置启动服务
  devServer: {
    contentBase: path.join(__dirname, './dist'),
    compress: true,
    port: 9000
  },
  devtool: 'source-map'
}